package com.timguan.render.dao.manager.cms;

import com.timguan.render.dao.domain.cms.CmsSubModuleDO;
import com.timguan.render.dao.domain.cms.CmsSubModuleDOExample;
import com.timguan.render.dao.persistence.cms.CmsSubModuleDOMapper;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * Created by guankaiqiang on 2015/3/20.
 */
public class CmsSubModuleManagerImpl {
    @Resource
    private CmsSubModuleDOMapper cmsSubModuleDOMapper;

    public int insert(CmsSubModuleDO record) {
        int id = 0;
        if (record == null) {
            return id;
        }
        Date now = new Date();
        record.setGmtCreate(now);
        record.setGmtModified(now);
        record.setIsDelete(0);
        cmsSubModuleDOMapper.insert(record);
        return record != null ? record.getId() : 0;
    }

    public int countByExample(CmsSubModuleDOExample condition) {
        int count = 0;
        if (condition == null) {
            return count;
        }
        return cmsSubModuleDOMapper.countByExample(condition);
    }

    public List<CmsSubModuleDO> selectByExample(CmsSubModuleDOExample condition) {
        List<CmsSubModuleDO> cmsSubModuleDOs = null;
        if (condition == null) {
            return cmsSubModuleDOs;
        }
        cmsSubModuleDOs = cmsSubModuleDOMapper.selectByExample(condition);
        return cmsSubModuleDOs;
    }

    public CmsSubModuleDO selectByPrimaryKey(int subModuleId) {
        return cmsSubModuleDOMapper.selectByPrimaryKey(subModuleId);
    }

    public int updateByPrimaryKeySelective(CmsSubModuleDO record) {
        int count = 0;
        if (record == null) {
            return count;
        }
        Date now = new Date();
        record.setGmtModified(now);
        count = cmsSubModuleDOMapper.updateByPrimaryKeySelective(record);
        return count;
    }
}
